package com.sinosoft.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.cache.annotation.CacheKey;
import com.netflix.hystrix.contrib.javanica.cache.annotation.CacheResult;
import com.sinosoft.domain.UserDTO;
import com.sinosoft.service.IServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

/**
 * @author loujiang
 * @date 2020/12/23 4:32 下午
 * @NOTE:
 */

@Service
public class RequestCacheServer {
    @Autowired
    IServer server;
    @CacheResult
    @HystrixCommand(commandKey = "userCacheKey")
    public UserDTO requestCache(@CacheKey String name) {
        System.out.println("request cache:" + name);
        UserDTO userDTO =null;
        userDTO=server.getUser(name);
        System.out.println("request cache:" + name);
        return userDTO;
    }
}
